<template>
  <div class="container">
    <div class="sort">组件</div>

    <div class="sort_label">HOC</div>
    <div
      class="label"
      v-for="item in HOC"
      :key="item.id"
      @click="handleClick(item)"
      :id="item.id === exampleId ? 'currentExample' : ''"
    >
      {{ item.name }} {{ item.label }}
    </div>

    <div class="sort_label">Data</div>

    <div class="sort_label"></div>
  </div>
</template>

<script lang="ts" setup>
import { watch, ref, onMounted } from 'vue'
import { useRouter, useRoute } from 'vue-router'
import { HOC } from '@/views/Example/example'

const router = useRouter()
const route = useRoute()

onMounted(() => {
  exampleId.value = route.params.exampleId as string
})

watch(
  () => route.params.exampleId,
  () => (exampleId.value = route.params.exampleId as string)
)

const exampleId = ref<string>('')

const handleClick = (item: any) => router.push('/example/' + item.id)
</script>

<style lang="less" scoped>
@fontStyle: comic Sans MS, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto,
  Oxygen, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;

.container {
  width: 100%;
  height: 100%;
  user-select: none;

  --leftPadding: 56px;

  > .sort {
    width: calc(100% - 100px);
    color: #333333;
    font-size: 16px;
    font-weight: 600;
    padding: 20px 10px 10px var(--leftPadding);
  }

  > .sort_label {
    width: calc(100% - 100px);
    letter-spacing: 2px;
    font-size: 13px;
    color: #999999;
    font-family: @fontStyle;
    padding: 20px 10px 10px var(--leftPadding);
  }

  > .label {
    width: calc(100% - 100px);
    font-size: 15px;
    font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB,
      Microsoft YaHei, SimSun, sans-serif;
    font-weight: 400;
    color: #444444;
    padding: 10px 10px 10px var(--leftPadding);
    transition: 0.3s;

    &:hover {
      cursor: pointer;
      color: #6a09da;
      translate: 16px 0;
    }
  }

  > #currentExample {
    background-color: #e5e9f2ee;
    border-radius: 8px;
    color: #6a09da;
    cursor: pointer;
    translate: 16px 0;
  }
}
</style>
